<template>
  <svg
    :class="svgClass"
    v-bind="$attrs"
    :style="{ color: color,height : height , width: width }"
    aria-hidden="true"
  >
    <use :xlink:href="iconName" />
  </svg>
</template>

<script setup >
import { computed } from "vue";
// 定义 props 接收
const props = defineProps({
  name: String,
  height: {
    type: String,
    default: '1em'
  },
  width: {
    type: String,
    default: '1em'
  },
  color: {
    type: String,
    default: 'transparent'
  }
})
const iconName = computed(() => `#icon-${props.name}`);
const svgClass = computed(() => {
  if (props.name) {
    return `svg-icon icon-${props.name}`;
  }
  return "svg-icon";
});
</script>

<style lang="scss" scoped>
.svg-icon {
  width: 1em;
  height: 1em;
  fill: currentColor;
  vertical-align: middle;
}
</style>